import 'package:flutter/material.dart';
import 'package:flutterapp/provider/global_app_model.dart';
import 'package:flutterapp/provider/global_user_model.dart';
import 'package:provider/provider.dart';

import 'common/util/global_utils.dart';
import 'common/widget/my_will_pop_scope.dart';
import 'main_page.dart';

void main() {
  //程序入口
  runApp(MultiProvider(
    providers: [
      ChangeNotifierProvider(create: (_) => GLobalAppModel()),
      ChangeNotifierProvider(create: (_) => GlobalUserModel()),
    ],
    child: MyApp(),
  ));

  //沉浸式状态栏
  GLobalUtils.immersiveStatusBar();
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: Provider.of<GLobalAppModel>(context).curTheme,
      darkTheme: ThemeData.dark(),
      home: MyWillPopScope(
        child: MainPage(),
      ),
    );
  }
}
